package io.renren.modules.impexp.controller;


/**
 * @description: 公共异常码定义
 */
public enum ResponseStatusEnum implements ResponseStatus {

    COMMON_EXCEL_TEMPLATE_ERROR(010001, "模板导出失败，请联系管理员"),
    COMMON_EXCEL_IMPORT_ERROR(010002, "Excel导入失败，请检查数据文件"),
    COMMON_EXCEL_EXPORT_ERROR(010003, "Excel导出失败，请联系管理员"),;
    private Integer status;

    private String message;

    ResponseStatusEnum(Integer status, String message) {
        this.status = status;
        this.message = message;
    }

    @Override
    public Integer status() {
        return status;
    }

    @Override
    public String message() {
        return message;
    }

    public static String getMessage(Integer status) {
        String message = "";
        ResponseStatusEnum[] values = values();
        for (ResponseStatusEnum item : values) {
            if (item.status.equals(status)) {
                message = item.message();
                break;
            }
        }
        return message;
    }

    public static ResponseStatusEnum of(Integer status) {
        if (status != null) {
            ResponseStatusEnum[] values = values();
            for (ResponseStatusEnum item : values) {
                if (item.status.equals(status)) {
                    return item;
                }
            }
        }
        return null;
    }
}
